using System;
using System.Collections;
using MySql.Data.MySqlClient;

namespace bOS.DataBase
{
	public class IntegerField : bOS.DataBase.bOSTable
	{
		private int _Id;

		public IntegerField(){}

		public IntegerField(int Id)
		{
			_Id = Id;
		}

		public int Id
		{
			get{ return _Id; }
			set{ _Id = value; }
		}
		
		public void ReadFromDataBase(MySqlDataReader reader)
		{
			this.Id = reader.GetInt32(0);
		}
	}

	
	public class IntegerColumn : CollectionBase, bOS.DataBase.bOSTable
	{
		public IntegerColumn()
		{
		}

		public int Add( IntegerField value ) 
		{
			return( List.Add( value ) );
		}

		public int IndexOf( IntegerField value ) 
		{
			return( List.IndexOf( value ) );
		}

		public void Insert( int index, IntegerField value ) 
		{
			List.Insert( index, value );
		}

		public void Remove( IntegerField value ) 
		{
			List.Remove( value );
		}

		public bool Contains( IntegerField value ) 
		{
			// If value is not of type SelectionValue, this will return false.
			return( List.Contains( value ) );
		}

		public void ReadFromDataBase(MySqlDataReader reader)
		{
			IntegerField bo = null;

			while ( reader.Read() )
			{
				bo = new IntegerField ();

				bo.ReadFromDataBase ( reader );

				this.Add ( bo );
			}
		}
	}

	
	public class StringField : bOS.DataBase.bOSTable
	{
		private string _Id;

		public StringField(){}

		public StringField(string Id)
		{
			_Id = Id;
		}

		public string Id
		{
			get{ return _Id; }
			set{ _Id = value; }
		}
		
		public void ReadFromDataBase(MySqlDataReader reader)
		{
			this.Id = reader.GetString(0);
		}
	}

	
	public class StringColumn : CollectionBase, bOS.DataBase.bOSTable
	{
		public StringColumn()
		{
		}

		public int Add( StringField value ) 
		{
			return( List.Add( value ) );
		}

		public int IndexOf( StringField value ) 
		{
			return( List.IndexOf( value ) );
		}

		public void Insert( int index, StringField value ) 
		{
			List.Insert( index, value );
		}

		public void Remove( StringField value ) 
		{
			List.Remove( value );
		}

		public bool Contains( StringField value ) 
		{
			// If value is not of type SelectionValue, this will return false.
			return( List.Contains( value ) );
		}

		public void ReadFromDataBase(MySqlDataReader reader)
		{
			StringField bo = null;

			while ( reader.Read() )
			{
				bo = new StringField ();

				bo.ReadFromDataBase ( reader );

				this.Add ( bo );
			}
		}
	}
}
